/*
 * Copyright 2013 Walter Lütgenau.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package offset.nodes.client.dialog.navigation.model;

import java.applet.Applet;
import offset.nodes.client.dialog.navigation.view.AbstractCardPanel;

/**
 *
 * @author Walter Lütgenau
 */
public abstract class NavigationModel {
    /** model has been update after invalidation */
    boolean valid = false;
    
    /**
     * Invalidate model
     */
    public void invalidate() {
        this.valid = false;
    }
    
    /**
     * Is the model valid?
     * 
     * @return the answer
     */
    public boolean isValid() {
        return valid;
    }
    
    /**
     * Update the model.
     * 
     * @throws Exception 
     */
    public synchronized void update() throws Exception {
        updatePage();
        valid = true;
    }
    
    /**
     * Update the page
     * @throws some exception
     */
    public abstract void updatePage() throws Exception;
    
    /**
     * Return the panel associated to the model.
     * 
     * @return the panel
     */
    public abstract AbstractCardPanel getPanel();
    
    /**
     * Set the panel
     * 
     * @param panel 
     */
    public abstract void initPanel() throws Exception;
    
    /**
     * Set the applet
     * 
     * @param applet 
     */
    public abstract void setApplet(Applet applet);
}
